﻿using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Platform.Storage;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using LiveChartsCore;
using LiveChartsCore.Drawing;
using LiveChartsCore.Measure;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.SkiaSharpView.Painting.Effects;
using LiveChartsCore.SkiaSharpView.VisualElements;
using MsBox.Avalonia.Enums;
using Nlnet.Avalonia.Controls;
using OfficeOpenXml;
using SkiaSharp;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using 畜牧业审核程序国产.Models;
using 畜牧业审核程序国产.Models.ToolsClass;

namespace 畜牧业审核程序国产.ViewModels
{
    internal partial class MyViewModelBase : ViewModelBase
    {
        //采用简单工厂模式
        #region 声明命令
        public RelayCommand ShowAllMsgCommand { get; set; }
        public RelayCommand ShowSingleMsgCommand { get; set; }
        public RelayCommand ShowAllOwnerMsgCommand { get; set; }
        public RelayCommand AllExpertToExcelCommand { get; set; }
        public RelayCommand SingleExpertToExcelCommand { get; set; }
        public RelayCommand QueryFrom1ToNewTableInDBCommand { get; set; }
        #endregion
        #region 声明绑定到Datagrid上的属性
        private DataTable _dTAll;

        public DataTable DTAll
        {
            get { return _dTAll; }
            set { SetProperty(ref _dTAll, value); }
        }
        private DataTable _dtSingleIndicator;
        
        public DataTable DTForSingleIndicator
        {
            get { return _dtSingleIndicator; }
            set { SetProperty(ref _dtSingleIndicator, value); }
        }
        #endregion
        #region 声明现在,上季度,环比季度的年度和季度,绑定到Textblock的Content

        public string StrYearNow
        {
            get { return Models.ToolsClass.Global.StrYearNow; }
        }
        public string StrSeasonNow
        {
            get => Models.ToolsClass.Global.StrSeasonNow;
        }
        public string StrYearAndSeasonNow
        {
            get { return Models.ToolsClass.Global.StrYearNow + Models.ToolsClass.Global.StrSeasonNow; }
        }
        //public static string StrYearNow
        //{
        //    get
        //    {
        //        return Model.Global.StrYearNow;
        //    }

        //}
        //public static string StrSeasonNow
        //{
        //    get
        //    {
        //        return Model.Global.StrSeasonNow;
        //    }
        //}
        //public static string StrYearPre
        //{
        //    get => Model.Global.StrYearPre;
        //}
        //public static string StrSeasonPre
        //{
        //    get => Model.Global.StrSeasonPre;
        //}
        //public static string StrYearYOY
        //{
        //    get => Model.Global.StrYearYOY;
        //}
        //public static string StrSeasonYOY
        //{
        //    get => Model.Global.StrSeasonYOY;
        //}
        #endregion
        #region 声明绑定到4个combobox的Itemsource的ObservableCollection
        private ObservableCollection<KeyValuePair<string, string>> _cityCln = new ObservableCollection<KeyValuePair<string, string>>();
        public ObservableCollection<KeyValuePair<string, string>> CityCln
        {
            get { return _cityCln; }
            set { SetProperty(ref _cityCln, value); }
        }
        private ObservableCollection<KeyValuePair<string, string>> _countryCln = new ObservableCollection<KeyValuePair<string, string>>();
        public ObservableCollection<KeyValuePair<string, string>> CountryCln
        {
            get { return _countryCln; }
            set { SetProperty(ref _countryCln, value); }
        }
        private ObservableCollection<KeyValuePair<string, string>> _townCln = new ObservableCollection<KeyValuePair<string, string>>();
        public ObservableCollection<KeyValuePair<string, string>> TownCln
        {
            get { return _townCln; }
            set { SetProperty(ref _townCln, value); }
        }
        private ObservableCollection<KeyValuePair<string, string>> _indicatorCln = new ObservableCollection<KeyValuePair<string, string>>();
        public ObservableCollection<KeyValuePair<string, string>> IndicatorCln
        {
            get { return _indicatorCln; }
            set { SetProperty(ref _indicatorCln, value); }
        }
        private ObservableCollection<KeyValuePair<string, string>> _canBePieOrCartIndicatorsCln = new ObservableCollection<KeyValuePair<string, string>>();

        public ObservableCollection<KeyValuePair<string, string>> CanBePieOrCartIndicatorsCln
        {
            get => _canBePieOrCartIndicatorsCln;
            set => SetProperty(ref _canBePieOrCartIndicatorsCln, value);
        }

        #endregion
        #region 声明用户选择了以后,selectedItem关联的 SelectedValue的属性或selectedItem.selectedItem是键值对,而selectedValue是键值对的值,配合selectedValuePath使用

        //private KeyValuePair<string, string> _selectedCity;
        //public KeyValuePair<string, string> SelectedCity
        //{
        //    get { return _selectedCity; }
        //    set
        //    {
        //        SetProperty(ref _selectedCity, value);
        //        //当用户选择了市以后,就要把县展现出来了
        //        //县可以包含"全部"
        //        if (value.Value != null)
        //        {
        //            ADOdotnet aDOForGetCountry = new ADOdotnet();
        //            string sqlForGetCountry = $"select 县代码,县 from {A210NameNow} where 市代码  = '{value.Key}' group by 县代码,县";
        //            DataTable dt = aDOForGetCountry.GetDataTable(sqlForGetCountry);
        //            if (dt.Rows.Count == 0 || dt == null)
        //            {
        //                CountryCln.Clear();
        //                CountryCln.Add(new KeyValuePair<string, string>("0", "未导入A210表或A210表导入错误"));
        //                return;
        //            }
        //            CountryCln.Clear();
        //            CountryCln.Add(new KeyValuePair<string, string>("0", "全部"));
        //            for (int i = 0; i < dt.Rows.Count; i++)
        //            {
        //                DataRow dtRow = dt.Rows[i];
        //                CountryCln.Add(new KeyValuePair<string, string>(dtRow[0].ToString(), dtRow[1].ToString()));
        //            }
        //        }
        //    }
        //}
        //private KeyValuePair<string, string> _selectedCountry;

        //public KeyValuePair<string, string> SelectedCountry
        //{
        //    get { return _selectedCountry; }
        //    set
        //    {
        //        SetProperty(ref _selectedCountry, value);
        //        if (Regex.IsMatch(value.Value, "全部"))
        //        {
        //            TownCln.Clear();
        //            TownCln.Add(new KeyValuePair<string, string>("0", "全部"));
        //            SelectedTown = TownCln[0];
        //        }
        //        else//如果县这里选择的不是全部,而是某个具体的县,那么要把所有乡镇和"全部"一起作为townCln的值
        //        {
        //            ADOdotnet aDOdotnet = new ADOdotnet();
        //            string sql = $"select 乡镇代码,乡 from {A210NameNow} WHERE 县代码 = '{SelectedCountry.Key}' group by 乡镇代码,乡";
        //            DataTable dt = aDOdotnet.GetDataTable(sql);
        //            if (dt == null || dt.Rows.Count == 0)
        //            {
        //                TownCln.Clear();
        //                TownCln.Add(new KeyValuePair<string, string>("0", "未导入A210表或A211表导入错误"));
        //                return;
        //            }
        //            TownCln.Clear();
        //            TownCln.Add(new KeyValuePair<string, string>("0", "全部"));
        //            for (int i = 0; i < dt.Rows.Count; i++)
        //            {
        //                DataRow dtRow = dt.Rows[i];
        //                TownCln.Add(new KeyValuePair<string, string>(dtRow[0].ToString(), dtRow[1].ToString()));

        //            }
        //            SelectedTown = TownCln[0];

        //        }
        //    }
        //}
        //private KeyValuePair<string, string> _selectedTown;

        //public KeyValuePair<string, string> SelectedTown
        //{
        //    get { return _selectedTown; }
        //    set { SetProperty(ref _selectedTown, value); }
        //}
        //private KeyValuePair<string, string> _selectedIndicator;

        //public KeyValuePair<string, string> SelectedIndicator
        //{
        //    get { return _selectedIndicator; }
        //    set { SetProperty(ref _selectedIndicator, value); }
        //}
        #endregion

        #region 直方图
        private LabelVisual _titleOfCartYOY;//同比直方图的标题

        public LabelVisual TitleOfCartYOY
        {
            get { return _titleOfCartYOY; }
            set => SetProperty(ref _titleOfCartYOY, value);
        }
        private LabelVisual _titleOfCartPre;//环比直方图的标题

        public LabelVisual TitleOfCartPre
        {
            get { return _titleOfCartPre; }
            set => SetProperty(ref _titleOfCartPre, value);
        }
        private LabelVisual _titleOfCartNow;//环比直方图的标题

        public LabelVisual TitleOfCartNow
        {
            get { return _titleOfCartNow; }
            set => SetProperty(ref _titleOfCartNow, value);
        }
        private ISeries[] _cartSeriesYOY;//同比直方图的内容

        public ISeries[] CartSeriesYOY
        {
            get { return _cartSeriesYOY; }
            set => SetProperty(ref _cartSeriesYOY, value);
        }
        private ISeries[] _cartSeriesPre;//环比直方图的内容

        public ISeries[] CartSeriesPre
        {
            get { return _cartSeriesPre; }
            set => SetProperty(ref _cartSeriesPre, value);
        }
        private ISeries[] _cartSeriesNow;//现在直方图的内容

        public ISeries[] CartSeriesNow
        {
            get { return _cartSeriesNow; }
            set => SetProperty(ref _cartSeriesNow, value);
        }

        private Axis[] _cartXAxisOfYOY;//同比直方图季度x轴

        public Axis[] CartXAxisOfYOY
        {
            get { return _cartXAxisOfYOY; }
            set { SetProperty(ref _cartXAxisOfYOY, value); }
        }
        private Axis[] _cartYAxisOfYOY;//同比直方图季度Y轴

        public Axis[] CartYAxisOfYOY
        {
            get { return _cartYAxisOfYOY; }
            set { SetProperty(ref _cartYAxisOfYOY, value); }
        }


        private Axis[] _cartXAxisOfPre;//环比直方图季度x轴

        public Axis[] CartXAxisOfPre
        {
            get { return _cartXAxisOfPre; }
            set { SetProperty(ref _cartXAxisOfPre, value); }
        }
        private Axis[] _cartYAxisOfPre;//同比直方图季度Y轴

        public Axis[] CartYAxisOfPre
        {
            get { return _cartYAxisOfPre; }
            set { SetProperty(ref _cartYAxisOfPre, value); }
        }


        private Axis[] _cartXAxisOfNow;//现在直方图季度x轴

        public Axis[] CartXAxisOfNow
        {
            get { return _cartXAxisOfNow; }
            set { SetProperty(ref _cartXAxisOfNow, value); }
        }
        private Axis[] _cartYAxisOfNow;//现在直方图季度Y轴

        public Axis[] CartYAxisOfNow
        {
            get { return _cartYAxisOfNow; }
            set { SetProperty(ref _cartYAxisOfNow, value); }
        }






        private ISeries[] _cartSeriesByTown;//分乡镇直方图的内容

        public ISeries[] CartSeriesByTown
        {
            get { return _cartSeriesByTown; }
            set => SetProperty(ref _cartSeriesByTown, value);
        }

        private Axis[] _cartXAxisByTown;//分乡镇直方图季度x轴

        public Axis[] CartXAxisOfByTown
        {
            get { return _cartXAxisByTown; }
            set { SetProperty(ref _cartXAxisByTown, value); }
        }
        private Axis _cartYAxisByTown;//分乡镇直方图季度Y轴

        public Axis CartYAxisByTown
        {
            get { return _cartYAxisByTown; }
            set { SetProperty(ref _cartYAxisByTown, value); }
        }



        #endregion
        #region 折线图
        private ISeries[] _lineSeries;

        public ISeries[] LineSeries
        {
            get { return _lineSeries; }
            set => SetProperty(ref _lineSeries, value);
        }

        private Axis[] _lineXAxis;//折线图x轴

        public Axis[] LineXAxis
        {
            get { return _lineXAxis; }
            set { SetProperty(ref _lineXAxis, value); }
        }
        private Axis[] _lineYAxis;//折线图Y轴

        public Axis[] LineYAxis
        {
            get { return _lineYAxis; }
            set { SetProperty(ref _lineYAxis, value); }
        }
        private LabelVisual _LineTltle;

        public LabelVisual LineTitle
        {
            get { return _LineTltle; }
            set => SetProperty(ref _LineTltle, value);
        }

        #endregion
        #region 饼图
        private ISeries[] _pieSeriesOfYOY = new ISeries[] {

        };
        // IEnumerable<ISeries>Series所有实现了inumerable接口的数据类型都可以存放,例如ISeries[] ,List<ISeries>,collection<ISeries>
        //ISeries[] PieSeries -> some PieSeries<double> -> one property named Values = double[] ,这里用了里氏转换,PieSeries是Iseries的子类
        //一个PieSeries是一块饼.dobule数组可以为1个值,如果是两个值的话
        //每个PieSeries是一块饼,如果PieSeries中的values数组中有n个值,那么这块饼的半径被分成n块
        //ISeries[] PieSeries = new ISeries[] { new PieSeries<double> { property here } };
        public ISeries[] PieSeriesOfYOY
        {
            get => _pieSeriesOfYOY;
            set { SetProperty(ref _pieSeriesOfYOY, value); }
        }
        private ISeries[] _pieSeriesOfPre = new ISeries[] { };
        public ISeries[] PieSeriesOfPre
        {
            get => _pieSeriesOfPre;
            set => SetProperty(ref _pieSeriesOfPre, value);
        }

        private ISeries[] _pieSeriesOfNow = new ISeries[] { };
        public ISeries[] PieSeriesOfNow
        {
            get => _pieSeriesOfNow;
            set => SetProperty(ref _pieSeriesOfNow, value);
        }

        private LabelVisual _titleOfPieSeriesYOY = new LabelVisual()
        {
            TextSize = 20,
            Padding = new LiveChartsCore.Drawing.Padding(10, 10, 10, 10),
            Paint = new SolidColorPaint()
            {
                Color = SKColors.Black,
                SKTypeface = SKFontManager.Default.MatchCharacter('汉')
            }
        };

        public LabelVisual TitleOfPieSeriesYOY
        {
            get { return _titleOfPieSeriesYOY; }
            set => SetProperty(ref _titleOfPieSeriesYOY, value);
        }

        private LabelVisual _titleOfPieSeriesPre = new LabelVisual();

        public LabelVisual TitleOfPieSeriesPre
        {
            get { return _titleOfPieSeriesPre; }
            set => SetProperty(ref _titleOfPieSeriesPre, value);
        }
        private LabelVisual _titleOfPieSeriesNow = new LabelVisual();

        public LabelVisual TitleOfPieSeriesNow
        {
            get { return _titleOfPieSeriesNow; }
            set => SetProperty(ref _titleOfPieSeriesNow, value);
        }




        private LabelVisual _titleOfPieChartForSingleIndicator = new LabelVisual() { };
        public LabelVisual TitleOfPieChartForSingleIndicator
        {
            get { return _titleOfPieChartForSingleIndicator; }
            set { SetProperty(ref _titleOfPieChartForSingleIndicator, value); }

        }


        #endregion
        #region 属性--为了解决livechart2中文乱码的问题
        //[ObservableProperty]
        private double _fontSize = 10;
        public double FontSize
        {
            get => _fontSize;
            set { SetProperty(ref _fontSize, value); }
        }

        private IPaint<LiveChartsCore.SkiaSharpView.Drawing.SkiaSharpDrawingContext> _textPaint
            = new SolidColorPaint()
            {
                Color = SKColors.DarkSlateGray,
                SKTypeface = SKFontManager.Default.MatchCharacter('汉')
            };

        public IPaint<LiveChartsCore.SkiaSharpView.Drawing.SkiaSharpDrawingContext> TextPaint { get => _textPaint; set => SetProperty(ref _textPaint, value); }


        private IPaint<LiveChartsCore.SkiaSharpView.Drawing.SkiaSharpDrawingContext> _textPaint2
              = new SolidColorPaint()
              {
                  Color = SKColors.DarkSlateGray,
                  SKTypeface = SKFontManager.Default.MatchCharacter('汉')
              };
        public IPaint<LiveChartsCore.SkiaSharpView.Drawing.SkiaSharpDrawingContext> TextPaint2
        {
            get => _textPaint2; set => SetProperty(ref _textPaint2, value);
        }
        #endregion


        protected bool IsCorrected(string tablename)
        {
            //MyDBOperator adoForAddSomeColumns = new MyDBOperator();改用单例模式
            MyDBOperator adoForAddSomeColumns = MyDBOperator.DBOperatorInstance;
            using (DataTable dt = adoForAddSomeColumns.GetDataTable($"select * from {tablename}"))
            {
                string[] columnNames = GetColumnNamesArr(dt);
                if (columnNames.Contains("已修正"))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }

        }
        public string[] GetColumnNamesArr(DataTable dt)
        {
            string[] columnNames = dt.Columns.Cast<DataColumn>()
                    .Select(x => x.ColumnName)
                    .ToArray();
            return columnNames;
        }
        protected void AddTw0TotalColumsToCart(DataRow Row, int NameColumn, string DataColumn1, string DataColumn2, ref List<double> ListOfNo1ColumnSeriesValues, ref List<double> ListOfNo2ColumnSeriesValues, ref List<string> ColumnsXAxisNames)
        {
            if (Row.IsNull(DataColumn1) == false || Row.IsNull(DataColumn2) == false)
            {
                if (Row.IsNull(DataColumn1))
                {
                    ListOfNo1ColumnSeriesValues.Add(0d);
                }
                else
                {
                    ListOfNo1ColumnSeriesValues.Add((double)Row[DataColumn1]);
                }
                if (Row.IsNull(DataColumn2))
                {
                    ListOfNo2ColumnSeriesValues.Add(0d);
                }
                else
                {
                    ListOfNo2ColumnSeriesValues.Add((double)Row[DataColumn2]);
                }
                ColumnsXAxisNames.Add(Row[NameColumn].ToString());
            }


            //bool flag = !Row.IsNull(DataColumn1) || !Row.IsNull(DataColumn2);
            //if (flag)
            //{
            //    bool flag2 = Row.IsNull(DataColumn1);
            //    if (flag2)
            //    {
            //        ListOfNo1ColumnSeriesValues.Add(0.0);
            //    }
            //    else
            //    {
            //        ListOfNo1ColumnSeriesValues.Add((double)Row[DataColumn1]);
            //    }
            //    bool flag3 = Row.IsNull(DataColumn2);
            //    if (flag3)
            //    {
            //        ListOfNo2ColumnSeriesValues.Add(0.0);
            //    }
            //    else
            //    {
            //        ListOfNo2ColumnSeriesValues.Add((double)Row[DataColumn2]);
            //    }
            //    ColumnsXAxisNames.Add((string)Row[NameColumn]);
            //}
        }
        protected PieSeries<T> GetOnePieSeries<T>(DataRow Row, string NameColumn, string DataColumn, int 余数)
        {
            PieSeries<T> pieSeries;
            if (余数 == 0)
            {
                pieSeries = new PieSeries<T>()
                {
                    Name = Row[NameColumn].ToString() + ":" + Row[DataColumn].ToString(),
                    Values = new T[] { (T)Row[DataColumn] },
                    DataLabelsSize = 10.0,
                    DataLabelsPadding = new Padding(0.0, 0.0, 0.0, 0.0),
                    DataLabelsPosition = PolarLabelsPosition.Outer,
                    Stroke = null,
                    DataLabelsPaint = new SolidColorPaint
                    {
                        SKFontStyle = SKFontStyle.Bold,
                        Color = SKColors.Black,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
                    //显示在图上每块上面的数值
                    DataLabelsFormatter = (mypoint) =>
                    {
                        if (mypoint.Coordinate.PrimaryValue > 1.5)
                        {
                            return $"{Row[NameColumn].ToString()}:{mypoint.Coordinate.PrimaryValue.ToString()}";
                        }
                        else
                        {
                            return " ";
                        }
                    },
                    Pushout = 5,
                    ToolTipLabelFormatter = point => string.Format("{0:P2}", point.StackedValue.Share),
                    // Fill = new SolidColorPaint(SKColors.Yellow),
                };
            }
            else
            {
                pieSeries = new PieSeries<T>()
                {
                    Name = Row[NameColumn].ToString() + ":" + Row[DataColumn].ToString(),
                    Values = new T[] { (T)Row[DataColumn] },
                    DataLabelsSize = 10.0,
                    DataLabelsPadding = new Padding(0.0, 0.0, 0.0, 0.0),
                    DataLabelsPosition = PolarLabelsPosition.Middle,
                    Stroke = null,
                    DataLabelsPaint = new SolidColorPaint
                    {
                        SKFontStyle = SKFontStyle.Bold,
                        Color = SKColors.Black,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
                    //显示在图上每块上面的数值
                    DataLabelsFormatter = (mypoint) =>
                    {
                        if (mypoint.Coordinate.PrimaryValue > 1.5)
                        {
                            return $"{Row[NameColumn].ToString()}:{mypoint.Coordinate.PrimaryValue.ToString()}";
                        }
                        else
                        {
                            return " ";
                        }
                    },
                    Pushout = 5,
                    ToolTipLabelFormatter = point => string.Format("{0:P2}", point.StackedValue.Share),
                };
            }
            return pieSeries;
        }
        protected PieSeries<T> GetOnePieSeries<T>(DataRow Row, string NameColumn, string DataColumn)
        {
            PieSeries<T> pieSeries;

            pieSeries = new PieSeries<T>()
            {
                Name = Row[NameColumn].ToString() + ":" + Row[DataColumn].ToString(),
                Values = new T[] { (T)Row[DataColumn] },
                DataLabelsSize = 10.0,
                DataLabelsPadding = new Padding(0.0, 0.0, 0.0, 0.0),
                DataLabelsPosition = PolarLabelsPosition.Middle,
                Stroke = null,
                DataLabelsRotation = 0,
                DataLabelsPaint = new SolidColorPaint
                {
                    SKFontStyle = SKFontStyle.Bold,
                    Color = SKColors.Black,
                    SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                },
                //显示在图上每块上面的数值
                DataLabelsFormatter = (mypoint) =>
                {
                    //if (mypoint.PrimaryValue > 1.5)
                    //{
                    //    return $"{Row[NameColumn].ToString()}:{mypoint.PrimaryValue.ToString()}";
                    //}
                    //else
                    //{
                    //    return " ";
                    //}
                    if (mypoint.StackedValue.Share > 0.02)
                    {
                        return $"{Row[NameColumn].ToString()}:{mypoint.Coordinate.PrimaryValue.ToString()}";
                    }
                    else
                    {
                        return " ";
                    }
                },
                Pushout = 5,
                ToolTipLabelFormatter = point => string.Format("{0:P2}", point.StackedValue.Share),
            };

            return pieSeries;
        }
        protected PieSeries<T> GetOnePieSeries<T>(DataRow Row, int Namecolumn, int datacolumn)
        {
            //if (Row.IsNull(datacolumn)==false && (double)Row[datacolumn] >0)
            //{

            //}
            PieSeries<T> pieSeries = new PieSeries<T>()
            {
                Name = Row[Namecolumn].ToString() + ":" + Row[datacolumn].ToString(),
                Values = new T[] { (T)Row[datacolumn] },
                DataLabelsSize = 10,
                DataLabelsPadding = new LiveChartsCore.Drawing.Padding(0, 0, 0, 0),
                DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Outer,
                Stroke = null,
                DataLabelsPaint = new SolidColorPaint
                {
                    SKFontStyle = SKFontStyle.Bold,
                    Color = SKColors.Black,
                    SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                },
                //显示在图上每块上面的数值
                DataLabelsFormatter = (mypoint) =>
                {
                    if (mypoint.Coordinate.PrimaryValue > 1.5)
                    {
                        return $"{Row[Namecolumn].ToString()}:{mypoint.Coordinate.PrimaryValue.ToString()}";
                    }
                    else
                    {
                        return " ";
                    }
                },
                Pushout = 5,
                ToolTipLabelFormatter = point => $"{point.StackedValue.Share:P2}",//鼠标悬停在每块上面时显示为百分比,前面的分乡镇自动加的。
            };
            return pieSeries;
        }
        protected PieSeries<T> GetOnePieSeries<T>(DataRow Row, int Namecolumn, string datacolumn)
        {
            PieSeries<T> pieSeries = new PieSeries<T>()
            {
                //Fill = new SolidColorPaint(SKColors.Yellow),
                Name = Row[Namecolumn].ToString() + ":" + Row[datacolumn].ToString(),
                Values = new T[] { (T)Row[datacolumn] },
                DataLabelsSize = 10,
                DataLabelsPadding = new LiveChartsCore.Drawing.Padding(0, 0, 0, 0),
                DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Outer,
                Stroke = null,
                DataLabelsPaint = new SolidColorPaint
                {
                    SKFontStyle = SKFontStyle.Bold,
                    Color = SKColors.Black,
                    SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                },
                //显示在图上每块上面的数值
                DataLabelsFormatter = (mypoint) =>
                {
                    if (mypoint.Coordinate.PrimaryValue > 1.5)
                    {
                        return $"{Row[Namecolumn].ToString()}:{mypoint.Coordinate.PrimaryValue.ToString()}";
                    }
                    else
                    {
                        return " ";
                    }
                },
                Pushout = 5,
                ToolTipLabelFormatter = point => $"{point.StackedValue.Share:P2}",//鼠标悬停在每块上面时显示为百分比,前面的分乡镇自动加的。
            };
            return pieSeries;
        }

        protected void AddOnePieSeriesToCircleList(DataRow Row, int 余数, int NameColumn, int Datacolumn, ref List<ISeries> ListOfPieSeries)
        {
            if (Row.IsNull(Datacolumn) == false && (double)Row[Datacolumn] > 0)
            {
                PieSeries<double> OnePieSeries = GetOnePieSeries<double>(Row, NameColumn, Datacolumn);
                //PieSeries<double> OnePieSeries = GetOnePieSeries<double>(Row, NameColumn, Datacolumn, 余数);//
                ListOfPieSeries.Add(OnePieSeries);
            }
            //bool flag = !Row.IsNull(Datacolumn) && (double)Row[Datacolumn] > 0.0;
            //if (flag)
            //{
            //    PieSeries<double> OnePieSeries = GetOnePieSeries<double>(Row, NameColumn, Datacolumn);
            //    ListOfPieSeries.Add(OnePieSeries);
            //}
        }
        protected void AddOnePieSeriesToCircleList(DataRow Row, int 余数, string NameColumn, string Datacolumn, ref List<ISeries> ListOfPieSeries)
        {
            if (Row.IsNull(Datacolumn) == false && (double)Row[Datacolumn] > 0)
            {
                //PieSeries<double> OnePieSeries = GetOnePieSeries<double>(Row, NameColumn, Datacolumn);
                PieSeries<double> OnePieSeries = GetOnePieSeries<double>(Row, NameColumn, Datacolumn, 余数);//
                ListOfPieSeries.Add(OnePieSeries);
            }
            //bool flag = !Row.IsNull(Datacolumn) && (double)Row[Datacolumn] > 0.0;
            //if (flag)
            //{
            //    PieSeries<double> OnePieSeries = GetOnePieSeries<double>(Row, NameColumn, Datacolumn);
            //    ListOfPieSeries.Add(OnePieSeries);
            //}
        }
        protected void AddOnePieSeriesToCircleList(DataRow Row, string NameColumn, string Datacolumn, ref List<ISeries> ListOfPieSeries)
        {
            if (Row.IsNull(Datacolumn) == false && (double)Row[Datacolumn] > 0)
            {
                PieSeries<double> OnePieSeries = GetOnePieSeries<double>(Row, NameColumn, Datacolumn);
                ListOfPieSeries.Add(OnePieSeries);
            }
            //if (Row.IsNull(Datacolumn) == false && (double)Row[Datacolumn] > 0.0)
            //{
            //    PieSeries<double> OnePieSeries = this.GetOnePieSeries<double>(Row, NameColumn, Datacolumn);
            //    ListOfPieSeries.Add(OnePieSeries);
            //}
        }
        #region SetPie

        public LabelVisual SetTitleOfPie(string TitleText)
        {
            LabelVisual LV = new LabelVisual
            {
                Text = TitleText,
                TextSize = 15,
                Paint = new SolidColorPaint()
                {
                    Color = SKColors.Black,
                    SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                },
            };
            return LV;
        }
        public void SetTitleOfPie(ref LabelVisual lv, string TitleText)
        {
            lv.Text = TitleText;
            lv.TextSize = 15;
            lv.Paint = new SolidColorPaint()
            {
                Color = SKColors.Black,
                SKTypeface = SKFontManager.Default.MatchCharacter('汉')
            };
        }
        #endregion
        #region SetColumns
        public LabelVisual GetTitleOfCart(string CartText)
        {
            LabelVisual lv = new LabelVisual()
            {
                Text = CartText,
                TextSize = 15,
                Paint = new SolidColorPaint()
                {
                    Color = SKColors.Black,
                    SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                },
                //Padding = new Padding(10.0, 10.0, 10.0, 10.0),//标题周边空间变大
            };
            return lv;
        }
        public ISeries[] SetColumnsSeries<T>(string name, List<T> ListColumnsValues)
        {
            ISeries[] ColumsSeries = new ISeries[]
            {
               new ColumnSeries<T>()
               {
                    Name = name,
                    Values = ListColumnsValues.ToArray(),
                    Padding = 5,
                    MaxBarWidth = double.MaxValue,
                    DataLabelsPosition = DataLabelsPosition.Top,
                    DataLabelsSize = 10,
                    DataLabelsFormatter = poin => poin.Coordinate.PrimaryValue.ToString(""),//c2是转成金额,并显示到第二位小数 c是转成基恩个,显示一位小数
                    ScalesYAt = 0,
                    DataLabelsPaint = new SolidColorPaint{
                        Color = SKColors.Black,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
               }

            };
            return ColumsSeries;
        }

        public ISeries[] SetColumnsSeries<T1, T2>(string name1, List<T1> ListColumnsValues1, string name2, List<T2> ListColumnsValues2)
        {
            ISeries[] ColumsSeries = new ISeries[]
            {
               new ColumnSeries<T1>()
               {
                    Name = name1,
                    Values = ListColumnsValues1.ToArray(),
                    Padding = 5,
                    MaxBarWidth = 30,
                    DataLabelsPosition = DataLabelsPosition.Middle,
                    DataLabelsSize = 10,
                    DataLabelsFormatter = poin => poin.Coordinate.PrimaryValue.ToString(""),//c2是转成金额,并显示到第二位小数 c是转成基恩个,显示一位小数
                    ScalesYAt = 0,
                    DataLabelsPaint = new SolidColorPaint{
                        Color = SKColors.Black,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
               },
               new ColumnSeries<T2>()
               {
                    Name = name2,
                    Values = ListColumnsValues2.ToArray(),
                    Padding = 5,
                    MaxBarWidth = 40,
                    DataLabelsPosition = DataLabelsPosition.Top,
                    DataLabelsSize = 10,
                    DataLabelsFormatter = poin => poin.Coordinate.PrimaryValue.ToString(""),//c2是转成金额,并显示到第二位小数 c是转成基恩个,显示一位小数
                    ScalesYAt = 0,
                    DataLabelsPaint = new SolidColorPaint{
                        Color = SKColors.Black,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },

               }
            };
            return ColumsSeries;
        }
        public Axis[] SetColumnsXAxis(string name, List<string> ListStrlabelsOfColumnsAxis)
        {
            Axis[] ColumnAxis = new Axis[]
            {
                new Axis()
                {
                    Name =name,
                    Padding = new Padding(5.0, 5.0, 5.0, 5.0),
                    NamePaint = new SolidColorPaint
                    {
                        Color = SKColors.Black,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉'),
                        SKFontStyle = SKFontStyle.BoldItalic
                    },
                    NamePadding = new Padding(0.0, 0.0, 0.0, 0.0),
                    NameTextSize = 15.0,
                    LabelsPaint = new SolidColorPaint
                    {
                        Color = SKColors.Blue,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
                    TextSize = 10.0,//设置X轴乡镇名称的字体大小
                    Labels = ListStrlabelsOfColumnsAxis.ToArray(),
                    LabelsRotation = 30.0,
                    SeparatorsPaint = new SolidColorPaint
                    {
                        Color = SKColors.Gray,
                        StrokeThickness = 1f,//设置X轴分割线的厚度
                                            //如何设置x乡镇的间隔
                        PathEffect = new DashEffect(new float[] { 3,3 }) //设置Y轴每个刻度横向的线的虚线的单条长度
                    },
                    TicksPaint = new SolidColorPaint//X轴刻度单位下面的点的颜色和厚度
                    {
                        Color = SKColors.Black,
                        StrokeThickness = 1.5f
                    },
                    SubticksPaint = new SolidColorPaint//X轴刻度两个单位之间的小点的颜色和厚度
                    {
                        Color = SKColors.Black,
                        StrokeThickness = 1f
                    },
                    SubseparatorsCount = 9 //x轴两个单位之间的竖线

                }
            };
            return ColumnAxis;
        }
        public Axis[] SetColumnsYAxis(string name)
        {
            Axis[] ColumnsYAxis = new Axis[]
            {
                new Axis
                {
                    Name = name,
                    NameTextSize = 15.0,
                    NamePaint = new SolidColorPaint
                    {
                        Color = SKColors.Red,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
                    NamePadding = new Padding(5,5,5,5),
                    Padding = new Padding(0.0, 5.0, 0.0, 0.0),
                    TextSize = 12.0,
                    LabelsPaint = new SolidColorPaint(SKColors.Green),//大刻度的数值的颜色
                    //TicksPaint = new SolidColorPaint(SKColors.Red),//刻度轴以及大刻度的颜色
                    SubticksPaint = new SolidColorPaint(SKColors.Red),//大刻度中间小刻度的颜色
                    LabelsAlignment = Align.Middle,
                    LabelsRotation = 0.0,
                    DrawTicksPath = true,
                    Position = AxisPosition.Start,
                    //SeparatorsPaint = new SolidColorPaint//大刻度的横线的颜色
                    //{
                    //    Color = SKColors.Black,
                    //    StrokeThickness = 1f,
                    //    PathEffect = new DashEffect(new float[]{3,3})
                    //},
                    //SubseparatorsPaint = new SolidColorPaint //两个大刻度中间的小刻度的颜色和厚度
                    //{
                    //    Color = SKColors.Black,
                    //    StrokeThickness = 0.5f
                    //},
                    SubseparatorsCount = 9,
                    ZeroPaint = new SolidColorPaint
                    {
                        Color = SKColors.Black,
                        StrokeThickness = 2f
                    },
                    TicksPaint = new SolidColorPaint
                    {
                        Color = SKColors.Orange,
                        StrokeThickness = 1.5f
                    }


                }

            };
            return ColumnsYAxis;

        }
        #endregion
        #region SetLine
        public LabelVisual SetTitleOfLine(string LineText)
        {
            LabelVisual lv = new LabelVisual()
            {
                Text = LineText,
                TextSize = 15,
                Paint = new SolidColorPaint()
                {
                    Color = SKColors.Black,
                    SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                },
                Padding = new Padding(5.0, 5.0, 5.0, 5.0),//标题周边空间变大
            };
            return lv;
        }
        public ISeries[] SetLineSeries<T1, T2>(string name1, List<T1> ListLineSeriesValues1, string name2, List<T2> listLineSeriesValues2)
        {
            ISeries[] LineSeries = new ISeries[]
            {
                new LineSeries<T1>()
                {
                    Name =name1,
                    Values = ListLineSeriesValues1.ToArray() ,
                    Fill = null,
                    DataLabelsFormatter =  point => point.Coordinate.PrimaryValue.ToString(""),
                    DataLabelsPaint = new SolidColorPaint(SKColors.Black),
                    DataLabelsPosition = DataLabelsPosition.Top,
                    ScalesXAt = 0,
                    DataLabelsPadding = new Padding(5.0,5.0, 5.0, 5.0),
                    DataPadding = new LiveChartsCore.Drawing.LvcPoint(1.0, 1.0),
                },
                new LineSeries<T2>()
                {
                    Name =name2,
                    Values = listLineSeriesValues2.ToArray(),
                    Fill = null,
                    DataLabelsFormatter = point => point.Coordinate.PrimaryValue.ToString(""),
                    DataLabelsPaint = new SolidColorPaint(SKColors.Black),
                    DataLabelsPosition = DataLabelsPosition.Bottom,
                    ScalesXAt = 0,
                    DataLabelsPadding = new Padding(5.0,5.0, 5.0, 5.0),
                    DataPadding = new LiveChartsCore.Drawing.LvcPoint(1.0, 1.0),
                }
            };
            return LineSeries;
        }
        public Axis[] SetLineXAxis(string name, List<string> ListStrlabelsOfLineAxis)
        {
            Axis[] LineAxis = new Axis[]
               {
                new Axis()
                {
                    Name =name,
                    Padding = new Padding(5.0, 5.0, 5.0, 5.0),

                    NamePaint = new SolidColorPaint
                    {
                        Color = SKColors.Black,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉'),
                        SKFontStyle = SKFontStyle.BoldItalic
                    },
                    NamePadding = new Padding(0.0, 0.0, 0.0, 0.0),
                    NameTextSize = 15.0,
                    LabelsPaint = new SolidColorPaint
                    {
                        Color = SKColors.Blue,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
                    TextSize = 10.0,//设置X轴乡镇名称的字体大小
                    Labels = ListStrlabelsOfLineAxis.ToArray(),
                    LabelsRotation = 30.0,
                    SeparatorsPaint = new SolidColorPaint
                    {
                        Color = SKColors.Gray,
                        StrokeThickness = 1f,//设置X轴分割线的厚度
                                            //如何设置x乡镇的间隔
                        PathEffect = new DashEffect(new float[] { 3,3 }) //设置Y轴每个刻度横向的线的虚线的单条长度
                    },
                    TicksPaint = new SolidColorPaint
                    {
                        Color = SKColors.Green,
                        StrokeThickness = 1.5f
                    },
                    SubticksPaint = new SolidColorPaint
                    {
                        Color = SKColors.Red,
                        StrokeThickness = 1f
                    },
                    SubseparatorsCount = 9

                }
               };
            return LineAxis;
        }
        public Axis[] SetLineYAxis(string name)
        {
            Axis[] LineYAxis = new Axis[]
            {
                new Axis
                {
                    Name = name,
                    NameTextSize = 15.0,
                    NamePaint = new SolidColorPaint
                    {
                        Color = SKColors.Red,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
                    NamePadding = new Padding(0.0, 20.0),
                    Padding = new Padding(5, 5.0, 5.0, 5.0),//Y轴上面有空余空间,不至于最上面的指标被遮挡
                    TextSize = 12.0,
                    LabelsPaint = new SolidColorPaint(SKColors.Green),
                    SubticksPaint = new SolidColorPaint(SKColors.Red),
                    LabelsAlignment = Align.End,
                    LabelsRotation = 15.0,
                    DrawTicksPath = true,
                    Position = 0,
                    //SeparatorsPaint = new SolidColorPaint//大刻度的横线的颜色
                    //{
                    //    Color = SKColors.Black,
                    //    StrokeThickness = 1f,
                    //    PathEffect = new DashEffect(new float[] { 3f, 3f  })
                    //},
                    //SubseparatorsPaint = new SolidColorPaint//两个大刻度中间的小刻度的颜色和厚度
                    //{
                    //    Color = SKColors.Black,
                    //    StrokeThickness = 0.5f
                    //},
                    SubseparatorsCount = 9,
                    ZeroPaint = new SolidColorPaint
                    {
                        Color = SKColors.Black,
                        StrokeThickness = 2f
                    },
                    TicksPaint = new SolidColorPaint
                    {
                        Color = SKColors.Orange,
                        StrokeThickness = 1.5f
                    }
                }

            };
            return LineYAxis;
        }
        #endregion
        #region 设置null
        protected ISeries[] SetNullPieSeries()
        {
            PieSeries<double> newPieSeries = new PieSeries<double>()
            {
                Name = "无数据",
                Values = new double[] { 1 },
                DataLabelsSize = 10.0,
                DataLabelsPadding = new Padding(0.0, 0.0, 0.0, 0.0),
                DataLabelsPosition = PolarLabelsPosition.Outer,
                Stroke = null,
                DataLabelsPaint = new SolidColorPaint
                {
                    SKFontStyle = SKFontStyle.Bold,
                    Color = SKColors.Black,
                    SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                },
                //显示在图上每块上面的数值
                DataLabelsFormatter = (mypoint) =>
                {
                    return "无数据";
                },
                Pushout = 5,
                ToolTipLabelFormatter = point => string.Format("{0:P2}", point.StackedValue.Share),
                // Fill = new SolidColorPaint(SKColors.Yellow),
            };
            List<ISeries> noDataPie = new List<ISeries>();
            noDataPie.Add(newPieSeries);
            ISeries[] pieSeries = noDataPie.ToArray();
            return pieSeries;
        }
        protected ISeries[] SetNullLineSeries()
        {
            List<double> nullValue = new List<double>() { 0, };
            ISeries[] LineSeries = new ISeries[]
            {

                new LineSeries<double>()
                {
                    Name ="无数据",
                    Values = nullValue.ToArray() ,
                    Fill = null,
                    DataLabelsFormatter =  point => point.Coordinate.PrimaryValue.ToString(""),
                    DataLabelsPaint = new SolidColorPaint(SKColors.Black),
                    DataLabelsPosition = DataLabelsPosition.Top,
                    ScalesXAt = 0,
                    DataLabelsPadding = new Padding(5.0,5.0, 5.0, 5.0),
                    DataPadding = new LiveChartsCore.Drawing.LvcPoint(1.0, 1.0),
                },
                new LineSeries<double>()
                {
                    Name ="无数据",
                    Values = nullValue.ToArray(),
                    Fill = null,
                    DataLabelsFormatter = point => point.Coordinate.PrimaryValue.ToString(""),
                    DataLabelsPaint = new SolidColorPaint(SKColors.Black),
                    DataLabelsPosition = DataLabelsPosition.Bottom,
                    ScalesXAt = 0,
                    DataLabelsPadding = new Padding(5.0,5.0, 5.0, 5.0),
                    DataPadding = new LiveChartsCore.Drawing.LvcPoint(1.0, 1.0),
                }
            };
            return LineSeries;
        }
        public ISeries[] SetNullColumnsSeries()
        {
            ISeries[] ColumsSeries = new ISeries[]
                {
               new ColumnSeries<double>()
               {
                    Name = "无数据",
                    Values = new double[]{0, },
                    Padding = 5,
                    MaxBarWidth = double.MaxValue,
                    DataLabelsPosition = DataLabelsPosition.Top,
                    DataLabelsSize = 10,
                    DataLabelsFormatter = poin => poin.Coordinate.PrimaryValue.ToString(""),//c2是转成金额,并显示到第二位小数 c是转成基恩个,显示一位小数
                    ScalesYAt = 0,
                    DataLabelsPaint = new SolidColorPaint{
                        Color = SKColors.Black,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
               }

                };
            return ColumsSeries;

        }
        protected Axis[] SetNullXAxis()
        {
            Axis[] ColumnAxis = new Axis[]
               {
                new Axis()
                {
                    Name ="无数据",
                    Padding = new Padding(5.0, 5.0, 5.0, 5.0),
                    NamePaint = new SolidColorPaint
                    {
                        Color = SKColors.Black,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉'),
                        SKFontStyle = SKFontStyle.BoldItalic
                    },
                    NamePadding = new Padding(0.0, 0.0, 0.0, 0.0),
                    NameTextSize = 15.0,
                    LabelsPaint = new SolidColorPaint
                    {
                        Color = SKColors.Blue,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
                    TextSize = 10.0,//设置X轴乡镇名称的字体大小
                    Labels = new string[]{ "无数据"},
                    LabelsRotation = 30.0,
                    SeparatorsPaint = new SolidColorPaint
                    {
                        Color = SKColors.Gray,
                        StrokeThickness = 1f,//设置X轴分割线的厚度
                                            //如何设置x乡镇的间隔
                        PathEffect = new DashEffect(new float[] { 3,3 }) //设置Y轴每个刻度横向的线的虚线的单条长度
                    },
                    TicksPaint = new SolidColorPaint//X轴刻度单位下面的点的颜色和厚度
                    {
                        Color = SKColors.Black,
                        StrokeThickness = 1.5f
                    },
                    SubticksPaint = new SolidColorPaint//X轴刻度两个单位之间的小点的颜色和厚度
                    {
                        Color = SKColors.Black,
                        StrokeThickness = 1f
                    },
                    SubseparatorsCount = 9 //x轴两个单位之间的竖线

                }
               };
            return ColumnAxis;
        }
        protected Axis[] SetNullYAxis()
        {
            Axis[] LineYAxis = new Axis[]
            {
                new Axis
                {
                    Name = "无数据",
                    NameTextSize = 15.0,
                    NamePaint = new SolidColorPaint
                    {
                        Color = SKColors.Red,
                        SKTypeface = SKFontManager.Default.MatchCharacter('汉')
                    },
                    NamePadding = new Padding(0.0, 20.0),
                    Padding = new Padding(5, 5.0, 5.0, 5.0),//Y轴上面有空余空间,不至于最上面的指标被遮挡
                    TextSize = 12.0,
                    LabelsPaint = new SolidColorPaint(SKColors.Green),
                    SubticksPaint = new SolidColorPaint(SKColors.Red),
                    LabelsAlignment = Align.End,
                    LabelsRotation = 15.0,
                    DrawTicksPath = true,
                    Position = 0,

                    SubseparatorsCount = 9,
                    ZeroPaint = new SolidColorPaint
                    {
                        Color = SKColors.Black,
                        StrokeThickness = 2f
                    },
                    TicksPaint = new SolidColorPaint
                    {
                        Color = SKColors.Orange,
                        StrokeThickness = 1.5f
                    }
                }

            };
            return LineYAxis;
        }
        #endregion
        private Window GetMainWindow()
        {
            if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                return desktop.MainWindow;
            }

            return null;
        }
        private async Task<bool> ExpertDataTableToExcel(DataTable dt, string name)
        {
            StaticLogger.SystemInfo("执行分析数据导出操作");
            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            using (var excelPackage = new ExcelPackage())
            {



                if (dt == null || dt.Rows.Count == 0)
                {
                    return false;
                }
                var sht = excelPackage.Workbook.Worksheets.Add(name);
                //写入表头
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    sht.Cells[1, i + 1].Value = dt.Columns[i].ColumnName;
                }
                //写入数据
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        sht.Cells[i + 2, j + 1].Value = dt.Rows[i][j];
                    }
                }




                var mainWindow = GetMainWindow();
                var topLevel = TopLevel.GetTopLevel(mainWindow);
                // 启动异步操作以打开对话框。
                var file = await topLevel.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
                {
                    Title = "保存文件",
                    SuggestedFileName = name+DateTime.Now.ToString("U"),
                    //SuggestedStartLocation = MyDataFolderOperator.AuditOutcomeFolderPathInAuditProgramFolder,
                });


                if (file != null)
                {
                    using (var steam = await file.OpenWriteAsync())
                    {
                        excelPackage.SaveAs(steam);
                    }
                    await MyMessagebox.ShowAsyncInMainWindow("数据库中正在使用的公式保存成功", Icon.Success);
                    return true;
                }
                else { return false; }
                //FileInfo excelFileInfo = new FileInfo(Path.Combine(MyDataFolderOperator.AuditOutcomeFolderPathInAuditProgramFolder, "数据库中在使用的审核公式.xlsx"));

                //excelPackage.SaveAs(excelFileInfo);


            }

        }
    }
}
